const { DataTypes } = require('sequelize');
const sequelize = require('../index');

module.exports = sequelize.define('Dict', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    comment: '字典ID'
  },
  label: {
    type: DataTypes.STRING,
    comment: '字典名称'
  },
  value: {
    type: DataTypes.STRING,
    comment: '字典值',
    get() {
      let value = this.getDataValue('value')
      if (value == 1) {
        value = true
      } else if (value == 0) {
        value = false
      }
      return value
    }
  },
  type: {
    type: DataTypes.STRING,
    comment: '字典类型'
  },
  desc: {
    type: DataTypes.STRING,
    comment: '字典描述'
  },
}, {
  tableName: 't_dict'
})
